package com.laolang.pluto.module.sys.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.laolang.pluto.common.persist.service.impl.BaseServiceImpl;
import com.laolang.pluto.module.sys.entity.SysUser;
import com.laolang.pluto.module.sys.mapper.SysUserMapper;
import com.laolang.pluto.module.sys.pojo.vo.SysUserVo;
import com.laolang.pluto.module.sys.service.SysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author laolang
 * @date 2021-08-07 00:04
 */
@RequiredArgsConstructor
@Service
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    private final SysUserMapper sysUserMapper;

    @Override
    public SysUser getByUsername(String username) {
        return getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
    }

    @Override
    public PageInfo<SysUserVo> listUserInfo(Integer page, Integer size, String username, Long projectId) {
        PageHelper.startPage(page, size);
        return new PageInfo<>(sysUserMapper.listUserInfo(username, projectId));
    }
}
